//manacher:
uses math;
var
    i,n,id,maxid,maxl:longint;
    s:ansistring;
    s1:array[0..200100]of char;
    p:array[0..200100]of longint;
begin
    while not(eof) do
        begin
            readln(s); if s='' then continue;
            id:=0; maxid:=0; s1:=''; maxl:=0;
            for i:=1 to length(s) do
                begin
                    s1[i<<1]:=s[i]; s1[(i<<1)+1]:='#';
                end;
            s1[0]:='$'; s1[1]:='#'; n:=(i<<1)+1;
            for i:=1 to n do
                begin
                    if maxid>i then p[i]:=min(p[2*id-i],maxid-i)
                                else p[i]:=1;
                    while s1[i+p[i]]=s1[i-p[i]] do inc(p[i]);
                    if p[i]+i>maxid then
                        begin maxid:=p[i]+i; id:=i; end;
                    if p[i]>maxl then maxl:=p[i];
                end;
            writeln(maxl-1);
        end;
end.

void get(){
    id=mx=mxl=0; s1='';
    rep(i,1,strlen(s)) s1[i*2]=s[i],s1[i*2+1]='#';
    s1[0]='$'; s1[1]='#'; n=strlen(s)*2+1;
    rep(i,1,n){
        p[i]=(mx>i) ? min(p[2*id-i],mx-i) : 1;
        while (s1[i+p[i]]==s1[i-p[i]]) p[i]++;
        if (p[i]+i>mx) mx=p[i]+i,id=i;
        mxl=max(mxl,p[i]);
    printf("%d\n",mxl-1);
}

//KMP:
var
    s,t:ansistring;
    i,k:longint;
    nxt:array[0..10001000]of longint;
procedure getnxt;
begin
    nxt[0]:=-1;
    for i:=1 to length(s) do
        begin
            k:=nxt[i-1];
            while (k>-1)and(s[i]<>s[k+1]) do k:=nxt[k];
            nxt[i]:=k+1;
        end;
end;

void getnxt(){
    nxt[0]=0; nxt[1]=0;
    rep(i,1,strlen(s)-1){
        for (j=nxt[i]; j && s[i]!=s[j]) j=nxt[j];
        f[i+1]=(p[i]==p[j]) ? j+1 : 0;
}

void find(){
    int n=strlen(t),m=strlen(s);
    getnxt(); j=0;
    rep(i,0,n-1){
        while (j && s[j]!=t[i]) j=nxt[j];
        if (s[j]==t[i]) j++;
        if (j==m) printf("%d\n",i-m-1);
    }
}

procedure work;
begin
    k:=0;
    for i:=1 to length(t) do
        begin
            while (k>-1)and(t[i]<>s[k+1]) do k:=nxt[k];
            if k=length(s)-1 then
                begin writeln(i-k); halt; end;
            inc(k);
        end;
end;
begin
    readln(s); readln(t); getnxt; work; writeln(-1);
end.